﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using PSDLib.Models;

namespace PSDManager
{
    public partial class CDRomInfo : UserControl
    {
        private delegate void UpdateCDRomTextEventHandler(string text);
        private UpdateCDRomTextEventHandler updateCDRomName;
        private UpdateCDRomTextEventHandler updateCDRomInfo;

        public string RecorderName { get; set; }
        public CDRomInfo()
        {
            InitializeComponent();

            lblNoBurn.Visible = true;
            burnJobInfo.Visible = false;

            updateCDRomName = new UpdateCDRomTextEventHandler(delegate (string name)
            {
                lblName.Text = name;
                this.Visible = !string.IsNullOrEmpty(name);
            });

            updateCDRomInfo = new UpdateCDRomTextEventHandler(delegate (string info)
            {
                lblInfo.Text = info;
            });
        }

        public void SetRecorderName(string name)
        {
            RecorderName = name;

            if (this.InvokeRequired)
            {
                this.Invoke(updateCDRomName, name);
            }
            else
            {
                updateCDRomName(name);
            }
        }

        //public void SetInfo(string info)
        //{
        //    if (this.InvokeRequired)
        //    {
        //        this.Invoke(updateCDRomInfo, info);
        //    }
        //    else
        //    {
        //        updateCDRomInfo(info);
        //    }
        //}

        public void SetBurnJob(BurnJob job)
        {
            if (job != null)
            {
                burnJobInfo.Visible = true;
                lblNoBurn.Visible = false;

                burnJobInfo.SetBurnJob(job);
            }
            else
            {
                burnJobInfo.Visible = false;
                lblNoBurn.Visible = true;
            }
        }
    }
}
